package niuke.array;

import java.util.Scanner;

/**
 * @author liyuhui
 * @date {DATE}
 * @description
 */
public class Sort {
    //目标：去重和排序
    public static void main(String[] args) {
        //更简单的方法：使用TreeSet
//        public static void main(String[] args) {
//
//
//            Scanner sc = new Scanner(System.in);
//            while(sc.hasNext()){
//
//                int num = sc.nextInt();
//                TreeSet<Integer> set = new TreeSet<Integer>();
//                for(int i = 0 ; i < num ;i++){
//                    int curr = sc.nextInt();
//                    set.add(curr);
//                }
//                for(Integer i : set){
//                    System.out.println(i);
//                }
//            }
//        }

        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            int size = scanner.nextInt();
            int[] arr = new int[size];

            for (int i = 0; i < size; i++) {
                arr[i] = scanner.nextInt();
            }

            quickSort(arr);
            printArray(arr);
        }

    }


    //处理重复元素
    private static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            if (i == 0 || arr[i] != arr[i-1]){
                System.out.println(arr[i]);
            }
        }
    }

    private static void quickSort(int[] arr) {
        //这里采用快排
        int n = arr.length;
        quickSort(arr, 0, n-1);
    }

    private static void quickSort(int[] arr, int l, int r) {
        if( l >= r )
            return;

        //找到定标点，使得大于arr[p]的都位于右边，小于arr[p]的都位于左边
        int p = partition(arr, l, r);
        quickSort(arr, l, p-1 );
        quickSort(arr, p+1, r);

    }

    private static int partition(int[] arr, int l, int r) {
        int v = arr[l];

        int j = l; // arr[l+1...j] < v ; arr[j+1...i) > v
        for( int i = l + 1 ; i <= r ; i ++ )
            if( arr[i] < v){
                j ++;
                swap(arr, j, i);
            }

        swap(arr, l, j);

        return j;
    }

    private static void swap(int[] arr, int i, int j) {
        int t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}
